from django.db import models
from django.utils.translation import ugettext_lazy as _


class Category(models.Model):
    name = models.CharField(max_length=100)
    description = models.TextField(blank=True, null=True)
    slug = models.SlugField(_('slug'), max_length=255, unique=True)

    
class Project(models.Model):
    name = models.CharField(_('name'), max_length=255)
    slug = models.SlugField(_('slug'), max_length=255, unique=True)
    category = models.ForeignKey(Category)
    creation_date = models.DateTimeField(_('creation date'), auto_now_add=True)
    icon = models.ImageField(upload_to='categories', max_length=255, null=True, blank=True)
    objects = models.Manager()
    description = models.TextField()
    requirements = models.TextField()
    downloadurl = models.URLField(max_length=255)
    sourcedurl = models.URLField(max_length=255)
   # screenshot = models.ImageField(upload_to='screenshots', max_length=255, null=True, blank=True)
    def __unicode__(self):
        return u'%s' % self.name;
    
    @models.permalink
    def get_absolute_url(self):
        return ('project_entry', (), {
            'slug': self.slug,
        })